** This do-file replicates table 4 in 
** Pl�mper, Thomas and Eric Neumayer. 2010. The Level of Democracy during Interregnum Periods: Recoding the polity2 Score, Political Analysis, 18 (2)
** To replicate the results, save the data-file of the same name into your working directory and run this do-file

use "PA replication_F&L.dta", replace
capture mi extract 0, clear

* model 4.1
logit onset warl  gdpenl  lpopl1  lmtnest ncontig Oil nwstate  instab ethfrac relfrac  anocl deml 
test anocl= deml
capture drop sample
ge sample=e(sample)

* model 4.2
logit onset warl  gdpenl  lpopl1  lmtnest ncontig Oil nwstate   instab ethfrac relfrac   anocpolity2minextl democpolity2minextl if sample==1
test anocpolity2minextl =democpolity2minextl

* model 4.3
logit onset warl  gdpenl  lpopl1  lmtnest ncontig Oil nwstate   instab ethfrac relfrac   anocpolity2predextl democpolity2predextl if sample==1
test anocpolity2predextl =democpolity2predextl

* model 4.4
capture drop *anocl_imp*
capture drop *deml_imp*
ge anocl_imp=anocl
ge deml_imp=deml
replace anocl_imp=. if interplusafftrans==1
replace deml_imp=. if interplusafftrans==1

capture mi extract 0, clear
mi set wide
mi register imputed anocl_imp deml_imp
mi impute mvn   anocl_imp deml_imp = onset warl  gdpenl  lpopl1  lmtnest ncontig Oil nwstate  ethfrac relfrac  western eeurop lamerica ssafrica asia  colbrit colfra,  add(100) replace force rseed(2232)
capture drop anocl_imp_dum
mi passive: ge anocl_imp_dum=round(anocl_imp)
mi passive: replace anocl_imp_dum=0 if anocl_imp_dum<0
mi passive: replace anocl_imp_dum=1 if anocl_imp_dum>0 & anocl_imp_dum<.
capture drop deml_imp_dum
mi passive: ge deml_imp_dum=round(deml_imp)
mi passive: replace deml_imp_dum=0 if deml_imp_dum<0
mi passive: replace deml_imp_dum=1 if deml_imp_dum>0 & deml_imp_dum<.
mi estimate (diff: _b[anocl_imp_dum]-_b[deml_imp_dum]), dots: logit onset warl  gdpenl  lpopl1  lmtnest ncontig Oil nwstate  instab ethfrac relfrac   anocl_imp_dum deml_imp_dum  if sample==1
mi testtransform diff

* model 4.5
capture drop *anocl_imp*
capture drop *deml_imp*
ge anocl_imp=anocl
ge deml_imp=deml
replace anocl_imp=. if interplusafftrans==1
replace deml_imp=. if interplusafftrans==1

capture mi extract 0, clear
mi set wide
mi register imputed anocl_imp deml_imp
mi impute mvn   anocl_imp deml_imp = anocpolity2minextl   democpolity2minextl anocpolity2maxextl  democpolity2maxextl,  add(100) replace force rseed(2232)
mi impute mvn   anocl_imp deml_imp = anocpolity2minextl   democpolity2minextl anocpolity2maxextl  democpolity2maxextl fhpr fhcl if year>1972,  replace force rseed(2232)
capture drop anocl_imp_dum
mi passive: ge anocl_imp_dum=round(anocl_imp)
mi passive: replace anocl_imp_dum=0 if anocl_imp_dum<0
mi passive: replace anocl_imp_dum=1 if anocl_imp_dum>0 & anocl_imp_dum<.
capture drop deml_imp_dum
mi passive: ge deml_imp_dum=round(deml_imp)
mi passive: replace deml_imp_dum=0 if deml_imp_dum<0
mi passive: replace deml_imp_dum=1 if deml_imp_dum>0 & deml_imp_dum<.
mi estimate (diff: _b[anocl_imp_dum]-_b[deml_imp_dum]), dots: logit onset warl  gdpenl  lpopl1  lmtnest ncontig Oil nwstate  instab ethfrac relfrac   anocl_imp_dum deml_imp_dum  if sample==1
mi testtransform diff


* model 4.6
capture drop *anocl_imp*
capture drop *deml_imp*
ge anocl_imp=anocl
ge deml_imp=deml
replace anocl_imp=. if interplusafftrans==1
replace deml_imp=. if interplusafftrans==1

capture mi extract 0, clear
mi set wide
mi register imputed anocl_imp deml_imp
mi impute mvn   anocl_imp deml_imp = onset warl  gdpenl  lpopl1  lmtnest ncontig Oil nwstate  ethfrac relfrac  western eeurop lamerica ssafrica asia  colbrit colfra  anocpolity2minextl  democpolity2minextl anocpolity2maxextl  democpolity2maxextl ,  add(100) replace force rseed(2232)
mi impute mvn   anocl_imp deml_imp = onset warl  gdpenl  lpopl1  lmtnest ncontig Oil nwstate  ethfrac relfrac  western eeurop lamerica ssafrica asia  colbrit colfra  anocpolity2minextl  democpolity2minextl anocpolity2maxextl  democpolity2maxextl  fhpr fhcl if year>1972,  replace force rseed(2232)
capture drop anocl_imp_dum
mi passive: ge anocl_imp_dum=round(anocl_imp)
mi passive: replace anocl_imp_dum=0 if anocl_imp_dum<0
mi passive: replace anocl_imp_dum=1 if anocl_imp_dum>0 & anocl_imp_dum<.
capture drop deml_imp_dum
mi passive: ge deml_imp_dum=round(deml_imp)
mi passive: replace deml_imp_dum=0 if deml_imp_dum<0
mi passive: replace deml_imp_dum=1 if deml_imp_dum>0 & deml_imp_dum<.
mi estimate (diff: _b[anocl_imp_dum]-_b[deml_imp_dum]), dots: logit onset warl  gdpenl  lpopl1  lmtnest ncontig Oil nwstate  instab ethfrac relfrac   anocl_imp_dum deml_imp_dum  if sample==1
mi testtransform diff

